<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 common-title">{{ lang_personal.withdrawalRecord }}</view>
				<view></view>
			</view>
		</view>

		<!-- 列表 -->
		<view>
			<mescroll-body height="calc(100vh - 98rpx - var(--status-bar-height))" ref="mescrollRef"
				@init="mescrollInit" @down="downCallback" @up="upCallback">
				<view style="padding: 0 30rpx;">
					<view v-for="(item, index) in dataList" :key="index" style="padding: 32rpx 0 34rpx; border-bottom: 1rpx solid #eeeeee;;">
						<view class="flex-center-between">
							<view>
								<view class="u-f-32 u-lh-44 flex-center linecamp-1">
									<view class="font-medio" :style="{ color: dealStatus(item.approveStatus).color }">
										<view>{{ lang_personal[dealStatus(item.approveStatus).key] }}</view>
										<view
											:style="{ width: '2rpx', height: '2rpx',borderRadius: '2rpx',background: dealStatus(item.approveStatus).color }">
										</view>
									</view>
									<view>paypal:{{ item.paypalAccount }}</view>
								</view>
							
								<view class="u-f-24 u-lh-34 color-grew">
									{{ dayjs(item.createTime).format('YYYY/MM/DD HH:mm:ss') }}
								</view>
							</view>
							<view :class="['flex-baseline u-lh-28 font-bold', item.approveStatus !== -1 ? 'color-red' : 'color-grew']">
								<view class="u-f-24">{{ lang_unit.money }}</view>
								<view class="u-f-40">{{ item.money || 0 }}</view>
							</view>
						</view>
						
						<view v-if="item.remark">{{ lang_common.remark }}：{{ item.remark || '' }}</view>
					</view>
					<!-- 留空 -->
					<view style="height: 200rpx;"></view>
				</view>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import {
		withdrawalPage
	} from '@/api/user/withdrawal.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				dataList: [],
			}
		},
		methods: {
			dealStatus(status = 0) {
				// -1表示审核失败，0待审核，1表示审核成功
				let list = [{
						color: '#007AFF',
						key: 'inReview',
						label: '审核中',
						value: 0
					},
					{
						color: '#00B578',
						key: 'paid',
						label: '已打款',
						value: 1
					},
					{
						color: '#FD1E43',
						key: 'rejected',
						label: '已拒绝',
						value: -1
					},
				]
				let item = list.find(item => item.value === status) || list[0]
				return item
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				let node = this.$refs['mescrollRef']
				withdrawalPage({
					pageNumber: page.num,
					pageSize: page.size
				}).then(res => {
					node && node.mescroll.endSuccess(res.list.length);
					if (page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(res.list); //追加新数据
				}).catch(() => {
					node && node.mescroll.endErr();
				})
			},
			downCallback() {
				let node = this.$refs['mescrollRef']
				node && node.mescroll.resetUpScroll()
			},
		}
	}
</script>

<style scoped lang="scss">

</style>
